package arraysAndStrings;

public class RemoveDuplicate_1_3 {
public static void main(String[] args) {
//	new RemoveDuplicate_1_3().testing();
	new RemoveDuplicate_1_3().removeDuplicateNxN(new StringBuilder("asdfdasfhjhjhjkadfasaa"));
}
public void testing(){
	for(int i =0; i<5; i++){
		System.out.println(i +" after "+ ++i);
	}
}

private void removeDuplicateNxN(StringBuilder string) {
	
	for (int i = 0; i < string.length(); i++) {
		int j= i+1;
		int k =i+1;
		System.out.println("String "+string);
		for(; j<string.length();j++){
			boolean duplicate= false;
			if(string.charAt(i)==string.charAt(j)){
				duplicate=true;
				while(string.charAt(i)==string.charAt(j) &&j<string.length()){j++;}
			}
			while(duplicate && string.charAt(i)!=string.charAt(j) &&j<string.length()){
				string.setCharAt(k, string.charAt(j));
				j++;k++;
			}
			
		}
		
	}
}
}
